<%@page import="com.hospital.model.UserInfo"%>
<%@page import="com.hospital.util.DbUtil"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link href="images/main.css" rel="stylesheet" type="text/css" />
<link  href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/trim.js"></script>
<script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	function sub(){
		document.forms["form"].submit();
	}
	var req;
    window.onload = function(){
    	//页面加载时的函数
    }
   	function createreq(){
   		if(window.XMLHttpRequest){
        	req = new XMLHttpRequest();
      	} else if(window.ActiveXObject){
        	req = new ActiveXObject("Microsoft.XMLHTTP");
      	}
   	}
    function Change_Select(){
    	//当科室下拉框的选项发生改变时调用该函数
    	createreq();
    	var deptidGet = document.getElementById("keshi").value;
      	var url = "../SelectServlet?deptidGet="+ escape(deptidGet);
      	if(req){
        	req.open("GET",url,true);
         	//指定回调函数为callback
        	req.onreadystatechange = callback;
        	req.send(null);
      	}
    }
    //回调函数
    function callback(){
      	if(req.readyState ==4){
        	if(req.status ==200){
          		parseMessage();//解析XML文档
        	} else{
          		alert("不能得到描述信息:" + req.status);
        	}
      	}
    }
    //解析返回xml的方法
    function parseMessage(){
      	var xmlDoc = req.responseXML.documentElement;//获得返回的XML文档
      	var xSel = xmlDoc.getElementsByTagName("select");
      	//获得XML文档中的所有<select>标记
      	var select_root = document.getElementById("doctorName");
      	//获得网页中的第二个下拉框
      	select_root.options.length=0;
      	//每次获得新的数据的时候先把每二个下拉框架的长度清0
     
      	for(var i=0;i<xSel.length;i++){
        	var xValue = xSel[i].childNodes[0].firstChild.nodeValue;
        	//获得每个<select>标记中的第一个标记的值,也就是<value>标记的值
        	var xText = xSel[i].childNodes[1].firstChild.nodeValue;
        	//获得每个<select>标记中的第二个标记的值,也就是<text>标记的值
        	var option = new Option(xText, xValue);
       	 	//根据每组value和text标记的值创建一个option对象
        	try{
          		select_root.add(option);//将option对象添加到第二个下拉框中
        	}catch(e){}
    	}
    } 
</script>
</head>
<body onload="init();">
	<jsp:include page="right_top.jsp"></jsp:include>
	<!-- TOP START -->
	<div id="right_font">
		<img src="images/main_14.gif" /> 您现在所在的位置：首页 → 挂号信息管理 → <span
			class="bfont">添加挂号信息</span>
	</div>
	<!-- TOP END -->
	<hr >
	<form action="OrderServlet?method=add" method="post" name="form" id="form">
		<table style="margin-top: 30px;">
			<tr height="30px;">
				<td><font color="#FF0000">*</font>用&nbsp;&nbsp;户：</td>
				<td>
					<select name="name" id="name">
					<%
						String sql = "select * from t_patient_info where root = 5 or 6";
						List<Map<String, Object>> list = DbUtil.find(sql);
						Map<String, Object> map = null;
						for (int i = 0; i < list.size(); i++) {
							map = (Map<String, Object>)list.get(i);
					%>
						<option value="<%=map.get("account")%>"><%=map.get("account") %></option>
					<% 
						}
					%>
					</select>
				</td>
				<td width="220px;">&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>年&nbsp;&nbsp;龄：</td>
				<td><input type="text" name="age" id="age" maxlength="3" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/></td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>科&nbsp;&nbsp;室：</td>
				<td>
					<select name="keshi" id="keshi" onchange="Change_Select()">
					<% 
						String sql_item = "select * from t_department where type = '科室'";
						List<Map<String, Object>> list_item = DbUtil.find(sql_item);
						Map<String, Object> map_item = null;
						for (int i = 0; i < list_item.size(); i++) {
							map_item = (Map<String, Object>)list_item.get(i);
					%>
						<option value="<%=map_item.get("deptId")%>"><%=map_item.get("name")%></option>
					<% 
						}
					%>	
					</select>
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>医&nbsp; 生：</td>
				<td>
					<select name="doctorName" id="doctorName">
						<option value="null">--请选择--</option>
					</select>
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>挂号类型：</td>
				<td>
					<select name="type" id="type">
					<% 
						String sql_type = "select * from t_dict where type = '挂号类型'";
						List<Map<String, Object>> list_type = DbUtil.find(sql_type);
						Map<String, Object> map_type = null;
						for (int i = 0; i < list_type.size(); i++) {
							map_type = (Map<String, Object>)list_type.get(i);
							if("true".equals(map_type.get("value"))){
					%>
						<option value="<%=map_type.get("item")%>"><%=map_type.get("item")%></option>
					<%} %>
					<% 
						}
					%>	
					</select>
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>简要情况：</td>
				<td>
					<input name="item" id="item"/>
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td colspan="2" align="center">
					&nbsp;
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td colspan="2" align="center">
					<input type="button" value="提交" onclick="sub();"/>&nbsp;&nbsp;
					<input type="button" value="返回" onclick="history.go(-1);" />
				</td>
				<td>&nbsp;</td>
			</tr>
		</table>
	</form>
</body>
</html>